<template>
	<view class="main">
		<view class="sex" v-if="index == 0">
			<view class="title font34">请选择你的性别 & 生日</view>
			<view class="SexOpt">
				<view class="girl">
					<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/GIRL%402x.png"></image>
				</view>
				<view class="boy">
					<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/BOY%402x.png"></image>
				</view>
			</view>
			<view class="example-body">
				<uni-datetime-picker type="date" :clear-icon="false" v-model="single"/>
				<view class="icon">
					<uni-icons type="down" size="20"></uni-icons>
				</view>
			</view>
		</view>
		<view class="name" v-if="index == 1">
			<view class="title font34">请选择你的头像 & 昵称</view>
			<view class="optbox">
				<view class="desc font24 mt-6">上传头像或选择一个默认头像</view>
				<view class="AvatarList">
					<view class="item" v-for="i in AvatarList" :key="i.id">
						<image :src="i.url"></image>
					</view>
				</view>
				<uni-section type="line" class="filePicker">
					<uni-file-picker limit="1" :del-icon="false" disable-preview file-mediatype="image"></uni-file-picker>
				</uni-section>
				<view class="input" @click="open('bottom')">
					<view class="text">{{name}}</view>
					<view class="icon">
						<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E5%88%B7%E6%96%B0.png"></image>
					</view>
				</view>
			</view>
			<uni-popup ref="popup" background-color="#fff" border-radius="16px 16px 0 0">
				<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
					<view class="btn">
						<view class="cancle" @click="close">取消</view>
						<view class="confirm" @click="confirm">确认</view>
					</view>
					<input class="uni-input" @input="inputname" maxlength="9" v-model="name" focus/>
					<view class="desc">最多可输入9个字符，支持中英文、数字、表情符号</view>
				</view>
			</uni-popup>
		</view>
		<view class="next" @click="next">
			<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%AE%AD%E5%A4%B4%402x.png"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				single: '',
				index: 0,
				name:'秀丽的念旧',
				AvatarList:[
					{
						id: 0,
						url: 'https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E5%9B%BE%E5%B1%82%207%402x.png'
					},
					{
						id: 1,
						url: 'https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E5%9B%BE%E5%B1%82%206%402x.png'
					},
					{
						id: 2,
						url: 'https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E5%9B%BE%E5%B1%82%208%402x.png'
					},
					{
						id: 3,
						url: 'https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E5%9B%BE%E5%B1%82%205%402x.png'
					}
				]
			};
		},
		methods: {
			next() {
				this.index++
				if(this.index == 2) {
					uni.navigateTo({
						url:"/pagesMain/hobby/hobby"
					})
				}
			},
			open(type) {
				this.type = type
				this.$refs.popup.open(type)
			},
			close() {
				this.$refs.popup.close()
			},
			confirm() {
				this.$refs.popup.close()
			},
			inputname(event) {
				this.name = event.target.value
			}
		}
	}
</script>

<style lang="scss">
.main {
	background-color: #fff;
	background-image: none;
	position: relative;
	.name {
		overflow: hidden;
	}
	.title {
		background-color: #fff;
		text-align: center;
		color: #333333;
		padding-top: 340rpx;
	}
	.SexOpt {
		display: flex;
		justify-content: space-between;
		width: 600rpx;
		margin: 100rpx auto 0;
		.girl, .boy {
			image {
				width: 260rpx;
				height: 260rpx;
			}
		}
	}
	.example-body {
		width: 600rpx;
		margin: 60rpx auto 0;
		position: relative;
		.uni-date {
			.uni-date-editor {
				.uni-date-x--border {
					border: none;
					border-radius: 15rpx;
					.uni-date-single {
						padding: 10rpx 0;
						background-color: #f6f6f6;
						border-radius: 15rpx;
						padding-left: 10rpx;
						color: #333333;
						.uni-icons {
							display: none;
						}
					}
				}
			}
		}
		.icon {
			position: absolute;
			right: 10rpx;
			top: 50%;
			transform: translateY(-50%);
		}
	}
	.optbox {
		position: absolute;
		left: 50%;
		width: 78%;
		height: 300rpx;
		margin-top: 100rpx;
		transform: translateX(-50%);
		border-radius: 40rpx;
		background-color: #F6F6F6;
		.desc {
			text-align: center;
			color: #9E9D9D;
			margin-top: 80rpx;
		}
		.AvatarList {
			display: flex;
			justify-content: space-around;
			margin-top: 45rpx;
			.item {
				width: 120rpx;
				height: 120rpx;
				image {
					width: 100%;
					height: 100%;
				}
			}
		}
		.filePicker {
			position: relative;
			top: -330rpx;
			left: calc(50% - 50rpx);
			.uni-file-picker {
				upload-image {
					.uni-file-picker__container {
						.file-picker__box {
							width: 22% !important;
							padding-top: 22% !important;
							.file-picker__box-content {
								border-radius: 50% !important;
								background-color: #fff !important;
								background: url(https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%9B%B8%E6%9C%BA%402x.png) no-repeat;
								background-size: 40% 40%;
								background-position: center;
								.is-add {
									.icon-add {
										background-color: transparent;
									}
								}
							}
						}
					}
				}
			}
		}
	}
	.input {
		display: flex;
		width: 100%;
		box-sizing: border-box;
		margin: -60rpx auto;
		padding: 25rpx 0;
		background-color: #f6f6f6;
		border-radius: 15rpx;
		padding-left: 25rpx;
		color: #333333;
		.text {
			flex: 1;
		}
		.icon {
			margin-right: 20rpx;
			image {
				width: 40rpx;
				height: 40rpx;
				transform: rotateZ(120deg);
			}
		}
	}
	.next {
		position: absolute;
		bottom: 300rpx;
		left: 50%;
		transform: translateX(-50%);
		width: 40%;
		height: 100rpx;
		background-color: #e7e7e7;
		border-radius: 50rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		image {
			width: 60rpx;
			height: 60rpx;
		}
	}
	.btn {
		display: flex;
		justify-content: space-between;
		width: 100%;
		margin: 0 auto;
		font-size: 32rpx;
		.cancle {
			color: #9E9D9D;
		}
		.confirm {
			color: #66CCCC;
		}
	}
	.popup-content {
		padding: 40rpx 60rpx;
		input {
			box-sizing: border-box;
			border-radius: 30rpx;
			color: #333333;
			font-size: 32rpx;
			width: 100%;
			margin-top: 50rpx;
			height: 160rpx;
			padding-left: 20rpx;
			background-color: #efefef;
		}
		.desc {
			margin-top: 20rpx;
			font-size: 24rpx;
			color: #888888;
		}
	}
	.uni-popup__wrapper {
		height: 300px;
		border-radius: 50rpx;
	}
}
</style>
